<html>
<head>
	<title><{.title}></title>
	<meta charset="utf-8">
	<link rel="stylesheet" type="text/css" href="./static/bootstrap/css/bootstrap.min.css">
	<script type="text/javascript" src="./static/jquery-2.0.3.min.js"></script>
	<script type="text/javascript" src="./static/vue.js"></script>

	<script type="text/javascript" src="./static/bootstrap/js/bootstrap.min.js"></script>
	<script type="text/javascript" src="./static/jquery.cookie.js"></script>
</head>

<body>
	<div class="container" id="app">
		<h1 class="sub-header"><{.title}></h1>
		<div class="panel panel-default">
			<div class="panel-body">
				<form class="form-horizontal">
				  <div class="form-group">
				    <label for="sid" class="col-sm-2 control-label">产品大号</label>
				    <div class="col-sm-2">
				      <input type="text" v-model="orderid" class="form-control" id="sid" placeholder="请输入产品大号">
				    </div>
				  </div>
				  <div class="form-group">
				    <label for="broker" class="col-sm-2 control-label">经销商</label>
				    <div class="col-sm-5">
				      <input type="text" v-model="broker" class="form-control" id="broker" placeholder="请输入经销商">
				    </div>
				  </div>
				  <div class="form-group">
				    <label for="address" class="col-sm-2 control-label">客户地址</label>
				    <div class="col-sm-10">
				      <input type="text" v-model="address" class="form-control" id="address" placeholder="请输入客户地址">
				    </div>
				  </div>
				  <div class="form-group">
				    <label for="pattern" class="col-sm-2 control-label">程数/总包</label>
				    <div class="col-sm-2">
				    	<select class="form-control" id="pattern">
						  <option value="1">程数</option>
						  <option value="2">总包</option>
						  <option value="3">程数+总包</option>
						</select>
				    </div>
				  </div>
				  <div class="form-group">
				    <label for="operator" class="col-sm-2 control-label">安装人员</label>
				    <div class="col-sm-5">
				      <input type="text" v-model="operator" class="form-control" id="operator" placeholder="请输入安装人员">
				    </div>
				  </div>
				  <div class="form-group">
				    <label for="booking" class="col-sm-2 control-label">预约安装时间</label>
				    <div class="col-sm-2">
				      <input type="text" v-model="booking" class="form-control" id="booking" placeholder="请输入预约安装时间">
				    </div>
				  </div>
				  <div class="form-group">
				    <label for="price" class="col-sm-2 control-label">收费金额(￥)</label>
				    <div class="col-sm-2">
				      <input type="text" v-model="price" class="form-control" id="price" placeholder="金额只能精确到分">
				    </div>
				  </div>
				  <div class="form-group">
				    <label for="diy_type" class="col-sm-2 control-label">厂装/店装</label>
				    <div class="col-sm-2">
				    	<select class="form-control" id="diy_type">
						  <option value="1">厂装</option>
						  <option value="2">店装</option>
						  <option value="3">厂装+店装</option>
						</select>
				    </div>
				  </div>
				  <div class="form-group">
				    <label for="suburb" class="col-sm-2 control-label">近郊/远郊</label>
				    <div class="col-sm-1">
				    	<select class="form-control" id="suburb">
						  <option value="1">近郊</option>
						  <option value="2">远郊</option>
						</select>
				    </div>
				  </div>
				  <div class="form-group">
				    <label for="desc" class="col-sm-2 control-label">备注</label>
				    <div class="col-sm-5">
				      <input id="desc" v-model="desc" type="text" class="form-control" placeholder="请输入备注">
				    </div>
				  </div>
				  <div class="form-group">
				    <label for="degree" class="col-sm-2 control-label">每日完成量</label>
				    <div class="col-sm-5">
				      <input type="text" v-model="degree" class="form-control" id="degree" placeholder="请输入每日完成量">
				    </div>
				  </div>
				  <div class="form-group">
				    <label for="dateline" class="col-sm-2 control-label">日期</label>
				    <div class="col-sm-2">
				      <input type="text" v-model="dateline" class="form-control" id="dateline" placeholder="请输入日期">
				    </div>
				  </div>
				  <div class="form-group">
				    <label for="validate" class="col-sm-2 control-label">验收情况</label>
				    <div class="col-sm-5">
				      <input type="text" v-model="validate" class="form-control" id="validate" placeholder="请输入验收情况">
				    </div>
				  </div>
				  <div class="form-group">
				    <label for="fee" class="col-sm-2 control-label">安装费(￥)</label>
				    <div class="col-sm-2">
				      <input type="text" v-model="fee" class="form-control" id="fee" placeholder="金额只能精确到分">
				    </div>
				  </div>
				  <div class="form-group">
				    <label for="satisfied" class="col-sm-2 control-label">回访满意度</label>
				    <div class="col-sm-5">
				      <input type="text" v-model="satisfied" class="form-control" id="satisfied" placeholder="请输入回访满意度">
				    </div>
				  </div>
				  <div class="form-group">
				    <label for="reason" class="col-sm-2 control-label">不满意原因</label>
				    <div class="col-sm-5">
				      <input type="text" v-model="reason" class="form-control" id="reason" placeholder="请输入不满意原因">
				    </div>
				  </div>
				  <div class="form-group">
				    <label for="feedback" class="col-sm-2 control-label">反馈信息</label>
				    <div class="col-sm-5">
				      <input type="text" v-model="feedback" class="form-control" id="feedback" placeholder="请输入反馈信息">
				    </div>
				  </div>
				  <div class="form-group">
				    <div class="col-sm-offset-2 col-sm-10">
				    	<button v-on:click="saveorder" class="btn btn-success">提交订单</button>
				    </div>
				  </div>
				</form>
			</div>
		</div>
	</div>
</body>
<script type="text/javascript">
    var app = new Vue({
        el: '#app',
        data: {
        	// V1 字段值
        	sid:'',
        	broker:'',
        	address:'',
        	pattern:'',
        	operator:'',
        	booking:'',
        	diy_type:'',
        	suburb:'',
        	desc:'',
        	degree:'',
        	dateline:'',
        	satisfied:'',
        	price:'',
        	reason:'',
        	feedback:'',
        	validate:'',
        	fee:'',
        	// 筛选参数
        	keyword:'',
        	orderid:'<{.orderid}>'
        	
        },
        methods:{
            //获取日志列表
            getinfo:function (event) {
                var _that = this;

                $.get("/getinfo", {keyword:_that.keyword, id:_that.orderid}, function (result) {
                	console.log(result);
                    if( result.errcode == 0 && result.data ){
                    	var info = result.data;
                        _that.sid = info.id;
                        _that.broker = info.broker;
                        _that.address = info.address;
                        _that.pattern = info.pattern;
                        _that.operator = info.operator;
                        _that.booking = info.booking;
                        _that.diy_type = info.diy_type;
                        _that.suburb = info.suburb;
                        _that.desc = info.desc;
                        _that.degree = info.degree;
                        _that.satisfied = info.satisfied;
                        _that.price = info.price;
                        _that.reason = info.reason;
                        _that.feedback = info.feedback;
                        _that.validate = info.validate;
                        _that.fee = info.fee;

                        // 处理日期
                        _that.dateline = info.dateline.String;
                    }
                });
            },

            // 保存表单信息
            saveorder:function(event){
            	console.log(_that.orderid);
            	return false;
            	var _that = this;

            	if ( !_that.orderid) {
            		alert("产品大号不能为空");
            		return false;
            	}

            	if ( !_that.broker) {
            		alert("经销商不能为空");
            		return false;
            	}

            	if ( !_that.address) {
            		alert("客户地址不能为空");
            		return false;
            	}

            	if ( !_that.pattern) {
            		alert("程数/总包不能为空");
            		return false;
            	}

            	var info = {};
            	info.id = _that.sid;
            	info.broker		= _that.broker;
            	info.address	= _that.address;
            	info.pattern	= _that.pattern;
            	info.operator	= _that.operator;
            	info.booking	= _that.booking;
            	info.diy_type	= _that.diy_type;
            	info.suburb		= _that.suburb;
            	info.desc		= _that.desc;
            	info.degree		= _that.degree;
            	info.satisfied	= _that.satisfied;
            	info.price		= _that.price;
            	info.reason		= _that.reason;
            	info.feedback	= _that.feedback;
            	info.validate	= _that.validate;
            	info.fee 		= _that.fee;

            	$.post('/saveinfo', {info:info}, function(result){
            		if(result.errcode == 0){
            			alert('提交成功');
            			window.location.href = "/homepage";
                    }else{
                    	alert('Failure:'+result.message);
                    	return false;
                    }
            	});
            },
        }
    });

    //初始化页面数据
    app.getinfo();
</script>
</html>